﻿using System;
class Bittris
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int points = 0, piece = 0;
        int[] console = { 0, 0, 0, 0 };
        char step;
        for (int i = 0; i <= (n - 1) / 4; i++)
        {
            piece = int.Parse(Console.ReadLine());
            console[0] = piece;
            //ShowGameConsole(console);
            for (int j = 0; j < 3; j++)
            {
                step = Convert.ToChar(Console.ReadLine());
                switch (step)
                {
                    case 'l':
                    case 'L':
                        {
                            if (console[j] < 128)
                            {
                                console[j] = console[j] << 1;
                            }
                            if ((console[j] & console[j + 1]) == 0)
                            {
                                console[j + 1] |= console[j];
                                console[j] = 0;
                            }

                            break;
                        }
                    case 'r':
                    case 'R':
                        {
                            if (console[j] % 2 == 0)
                            {
                                console[j] >>= 1;
                            }
                            if ((console[j] & console[j + 1]) == 0)
                            {
                                console[j + 1] |= console[j];
                                console[j] = 0;
                            }
                            break;
                        }
                    case 'd':
                    case 'D':
                        {
                            if ((console[j] & console[j + 1]) == 0)
                            {
                                console[j + 1] |= console[j];
                                console[j] = 0;
                            } break;
                        }
                    default:
                        break;
                }

                if (console[j] == 255)
                {
                    console[j] = 0;
                    points += bitCounts(piece) * 10;
                    piece = 0;
                }


                //ShowGameConsole(console);
            }
            points += bitCounts(piece);
        }
        Console.WriteLine(points);
    }





    private static void ShowGameConsole(int[] console)
    {
        for (int i = 0; i < 4; i++)
        {
            Console.WriteLine("{0}", Convert.ToString(console[i], 2).PadLeft(8, '0'));
        }
        Console.WriteLine();
    }


    private static int bitCounts(int num)
    {
        int counter = 0;
        for (int i = 0; i < 8; i++)
        {
            if (num % 2 == 1)
            {
                counter++;
            }
            num >>= 1;
        }
        return counter;
    }
}